package com.example.datasourcedemo.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class DataService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public List<Map<String, Object>> queryData() {
        String dbName = jdbcTemplate.queryForObject("SELECT DATABASE()", String.class);
        System.out.println("当前数据库：" + dbName);
        List<Map<String, Object>> mapList = jdbcTemplate.queryForList("select * from student");
        return mapList;
    }
}
